from numpy import linspace,sum

class PE_calculator:
    def __init__(self):
       self.X1 = 0
       self.X2 = 0
       self.a = 0  # 判断是a元系

    def PE_2(self,X1,X2,l0,l1,l2,l3):
        return X1 * X2 * (l0 + l1 * (X1-X2) + l2 * pow(X1-X2, 2) + l3 * pow(X1-X2, 3))

    def integrate(self,y,a, b, num_points):
        n_values = linspace(a, b, num_points)
        delta_n = (b - a) / (num_points - 1)
        y_values = y(n_values)
        integrate = (delta_n / 2) * (y_values[0] + 2 * sum(y_values[1:-1]) + y_values[-1])
        return integrate

    def eta_1(self, l0_12, l1_12, l2_12, l3_12, l0_13, l1_13, l2_13, l3_13):
        eta0 = l0_12 - l0_13
        eta1 = l1_12 - l1_13
        eta2 = l2_12 - l2_13
        eta3 = l3_12 - l3_13
        # 积分
        n = linspace(0, 1, 10000)
        delta_n = 0.0001
        y = pow(n, 2) * pow(1-n, 2) * pow(eta0+eta1*(2*n-1)+eta2*pow(2*n-1, 2)+eta3*pow(2*n-1, 3), 2)
        integrate1 = (delta_n / 2) * (y[0] + 2 * sum(y[1:-1]) + y[-1])

        return integrate1

    def eta_2(self, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23):
        eta0 = l0_12 - l0_23
        eta1 = - l1_12 - l1_23
        eta2 = l2_12 - l2_23
        eta3 = - l3_12 - l3_23
        # 积分
        n = linspace(0, 1, 10000)
        delta_n = 0.0001
        y = pow(n, 2) * pow(1-n, 2) * pow(eta0+eta1*(2*n-1)+eta2*pow(2*n-1, 2)+eta3*pow(2*n-1, 3), 2)
        integrate2 = (delta_n / 2) * (y[0] + 2 * sum(y[1:-1]) + y[-1])

        return integrate2

    def eta_3(self, l0_13, l1_13, l2_13, l3_13, l0_23, l1_23, l2_23, l3_23):
        eta0 = l0_13 - l0_23
        eta1 = - l1_13 + l1_23
        eta2 = l2_13 - l2_23
        eta3 = -l3_13 + l3_23
        # 积分
        n = linspace(0, 1, 10000)
        delta_n = 0.0001
        y = pow(n, 2) * pow(1-n, 2) * pow(eta0+eta1*(2*n-1)+eta2*pow(2*n-1, 2)+eta3*pow(2*n-1, 3), 2)
        integrate3 =  (delta_n / 2) * (y[0] + 2 * sum(y[1:-1]) + y[-1])

        return integrate3

    def GSM(self,x1,x2,x3,l0_12,l1_12,l2_12,l3_12,l0_23,l1_23,l2_23,l3_23,l0_13,l1_13,l2_13,l3_13):

        eta_1 = self.eta_1(l0_12, l1_12, l2_12, l3_12, l0_13, l1_13, l2_13, l3_13)
        eta_2 = self.eta_2(l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23)
        eta_3 = self.eta_3(l0_13, l1_13, l2_13, l3_13, l0_23, l1_23, l2_23, l3_23)
        print(eta_1,eta_2,eta_3)

        # 希腊字母 ksai
        xi_12 = eta_1/(eta_1+eta_2)
        xi_23 = eta_2/(eta_2+eta_3)
        xi_13 = eta_3/(eta_3+eta_1)

        temp1 = x1*x2/((x1+x3*xi_12)*(1-x1-x3*xi_12))*self.PE_2(x1+x3*xi_12,1-x1-x3*xi_12,l0_12,l1_12,l2_12,l3_12)
        temp2 = x2*x3/((x2+x1*xi_23)*(1-x2-x1*xi_23))*self.PE_2(x2+x1*xi_23,1-x2-x1*xi_23,l0_23,l1_23,l2_23,l3_23)
        temp3 = x3*x1/((x3+x2*xi_13)*(1-x3-x2*xi_13))*self.PE_2(1-x3-x2*xi_13,x3+x2*xi_13,l0_13,l1_13,l2_13,l3_13)
        PE = temp1+temp2+temp3

        return PE
    def GSM_4(self, x1, x2, x3, x4, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
                   l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34):
        return 1
    def GSM_5(self, x1, x2, x3, x4, x5, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
                   l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34,l0_15,l1_15,l2_15,l3_15,
                l0_25,l1_25,l2_25,l3_25,l0_35,l1_35,l2_35,l3_35,l0_45,l1_45,l2_45,l3_45):
        return 1
    def GSM_6(self, x1, x2, x3, x4, x5, x6, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
        l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34,l0_15,l1_15,l2_15,l3_15,
        l0_25,l1_25,l2_25,l3_25,l0_35,l1_35,l2_35,l3_35,l0_45,l1_45,l2_45,l3_45,
        l0_16,l1_16,l2_16,l3_16,l0_26,l1_26, l2_26, l3_26, l0_36,l1_36,l2_36,l3_36,
        l0_46,l1_46,l2_46,l3_46,l0_56,l1_56,l2_56,l3_56):
        return 1
    def Muggianu(self, x1, x2, x3, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13):

        temp12 = 4 * x1 * x2 /((1+x1-x2) * (1-x1+x2)) * self.PE_2((1+x1-x2)/2,(1+x2-x1)/2,l0_12,l1_12, l2_12, l3_12)
        temp23 = 4*x2*x3/((1+x2-x3)*(1-x2+x3)) * self.PE_2((1+x2-x3)/2,(1+x3-x2)/2,l0_23,l1_23, l2_23, l3_23)
        temp13 = 4*x1*x3/((1+x1-x3)*(1-x1+x3)) * self.PE_2((1+x1-x3)/2,(1+x3-x1)/2, l0_13, l1_13, l2_13, l3_13)

        PE = temp12 + temp23 + temp13

        return PE
    def Muggianu_4(self, x1, x2, x3, x4, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
        l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34):

        temp12 = 4 * x1 * x2 /((1+x1-x2) * (1-x1+x2)) * self.PE_2((1+x1-x2)/2,(1+x2-x1)/2,l0_12, l1_12, l2_12, l3_12)
        temp23 = 4 * x2 * x3 /((1+x2-x3) * (1-x2+x3)) * self.PE_2((1+x2-x3)/2,(1+x3-x2)/2,l0_23, l1_23, l2_23, l3_23)
        temp13 = 4 * x3 * x1 /((1+x1-x3) * (1-x1+x3)) * self.PE_2((1+x1-x3)/2,(1+x3-x1)/2,l0_13, l1_13, l2_13, l3_13)
        temp14 = 4 * x1 * x4 /((1+x1-x4) * (1-x1+x4)) * self.PE_2((1+x1-x4)/2,(1+x4-x1)/2,l0_14, l1_14, l2_14, l3_14)
        temp24 = 4 * x2 * x4 /((1+x2-x4) * (1-x2+x4)) * self.PE_2((1+x2-x4)/2,(1+x4-x2)/2,l0_24, l1_24, l2_24, l3_24)
        temp34 = 4 * x3 * x4 /((1+x3-x4) * (1-x3+x4)) * self.PE_2((1+x3-x4)/2,(1+x4-x3)/2,l0_34, l1_34, l2_34, l3_34)

        PE = temp12 + temp23 + temp13 +temp14 + temp24 + temp34

        return PE
    def Muggianu_5(self, x1, x2, x3, x4, x5, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
                   l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34,l0_15,l1_15,l2_15,l3_15,
                l0_25,l1_25,l2_25,l3_25,l0_35,l1_35,l2_35,l3_35,l0_45,l1_45,l2_45,l3_45):

        temp12 = 4 * x1 * x2 /((1+x1-x2) * (1-x1+x2)) * self.PE_2((1+x1-x2)/2,(1+x2-x1)/2,l0_12, l1_12, l2_12, l3_12)
        temp23 = 4 * x2 * x3 /((1+x2-x3) * (1-x2+x3)) * self.PE_2((1+x2-x3)/2,(1+x3-x2)/2,l0_23, l1_23, l2_23, l3_23)
        temp13 = 4 * x3 * x1 /((1+x1-x3) * (1-x1+x3)) * self.PE_2((1+x1-x3)/2,(1+x3-x1)/2,l0_13, l1_13, l2_13, l3_13)
        temp14 = 4 * x1 * x4 /((1+x1-x4) * (1-x1+x4)) * self.PE_2((1+x1-x4)/2,(1+x4-x1)/2,l0_14, l1_14, l2_14, l3_14)
        temp24 = 4 * x2 * x4 /((1+x2-x4) * (1-x2+x4)) * self.PE_2((1+x2-x4)/2,(1+x4-x2)/2,l0_24, l1_24, l2_24, l3_24)
        temp34 = 4 * x3 * x4 /((1+x3-x4) * (1-x3+x4)) * self.PE_2((1+x3-x4)/2,(1+x4-x3)/2,l0_34, l1_34, l2_34, l3_34)
        temp15 = 4 * x1 * x5 /((1+x1-x5) * (1-x1+x5)) * self.PE_2((1+x1-x5)/2,(1+x5-x1)/2,l0_15, l1_15, l2_15, l3_15)
        temp25 = 4 * x2 * x5 /((1+x2-x5) * (1-x2+x5)) * self.PE_2((1+x2-x5)/2,(1+x5-x2)/2,l0_25, l1_25, l2_25, l3_25)
        temp35 = 4 * x3 * x5 /((1+x3-x5) * (1-x3+x5)) * self.PE_2((1+x3-x5)/2,(1+x5-x3)/2,l0_35, l1_35, l2_35, l3_35)
        temp45 = 4 * x4 * x5 /((1+x4-x5) * (1-x4+x5)) * self.PE_2((1+x4-x5)/2,(1+x5-x4)/2,l0_45, l1_45, l2_45, l3_45)

        PE = temp12 + temp23 + temp13 +temp14 + temp24 + temp34 + temp15 + temp25 + temp35 + temp45

        return PE
    def Muggianu_6(self, x1, x2, x3, x4, x5, x6, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
        l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34,l0_15,l1_15,l2_15,l3_15,
                l0_25,l1_25,l2_25,l3_25,l0_35,l1_35,l2_35,l3_35,l0_45,l1_45,l2_45,l3_45,
        l0_16,l1_16,l2_16,l3_16,l0_26,l1_26, l2_26, l3_26, l0_36,l1_36,l2_36,l3_36,
        l0_46,l1_46,l2_46,l3_46,l0_56,l1_56,l2_56,l3_56):

        temp12 = 4 * x1 * x2 /((1+x1-x2) * (1-x1+x2)) * self.PE_2((1+x1-x2)/2,(1+x2-x1)/2,l0_12, l1_12, l2_12, l3_12)
        temp23 = 4 * x2 * x3 /((1+x2-x3) * (1-x2+x3)) * self.PE_2((1+x2-x3)/2,(1+x3-x2)/2,l0_23, l1_23, l2_23, l3_23)
        temp13 = 4 * x3 * x1 /((1+x1-x3) * (1-x1+x3)) * self.PE_2((1+x1-x3)/2,(1+x3-x1)/2,l0_13, l1_13, l2_13, l3_13)
        temp14 = 4 * x1 * x4 /((1+x1-x4) * (1-x1+x4)) * self.PE_2((1+x1-x4)/2,(1+x4-x1)/2,l0_14, l1_14, l2_14, l3_14)
        temp24 = 4 * x2 * x4 /((1+x2-x4) * (1-x2+x4)) * self.PE_2((1+x2-x4)/2,(1+x4-x2)/2,l0_24, l1_24, l2_24, l3_24)
        temp34 = 4 * x3 * x4 /((1+x3-x4) * (1-x3+x4)) * self.PE_2((1+x3-x4)/2,(1+x4-x3)/2,l0_34, l1_34, l2_34, l3_34)
        temp15 = 4 * x1 * x5 /((1+x1-x5) * (1-x1+x5)) * self.PE_2((1+x1-x5)/2,(1+x5-x1)/2,l0_15, l1_15, l2_15, l3_15)
        temp25 = 4 * x2 * x5 /((1+x2-x5) * (1-x2+x5)) * self.PE_2((1+x2-x5)/2,(1+x5-x2)/2,l0_25, l1_25, l2_25, l3_25)
        temp35 = 4 * x3 * x5 /((1+x3-x5) * (1-x3+x5)) * self.PE_2((1+x3-x5)/2,(1+x5-x3)/2,l0_35, l1_35, l2_35, l3_35)
        temp45 = 4 * x4 * x5 /((1+x4-x5) * (1-x4+x5)) * self.PE_2((1+x4-x5)/2,(1+x5-x4)/2,l0_45, l1_45, l2_45, l3_45)
        temp16 = 4 * x1 * x6 /((1+x1-x6) * (1-x1+x6)) * self.PE_2((1+x1-x6)/2,(1+x6-x1)/2,l0_16, l1_16, l2_16, l3_16)
        temp26 = 4 * x2 * x6 /((1+x2-x6) * (1-x2+x6)) * self.PE_2((1+x2-x6)/2,(1+x6-x2)/2,l0_26, l1_26, l2_26, l3_26)
        temp36 = 4 * x3 * x6 /((1+x3-x6) * (1-x3+x6)) * self.PE_2((1+x3-x6)/2,(1+x6-x3)/2,l0_36, l1_36, l2_36, l3_36)
        temp46 = 4 * x4 * x6 /((1+x4-x6) * (1-x4+x6)) * self.PE_2((1+x4-x6)/2,(1+x6-x4)/2,l0_46, l1_46, l2_46, l3_46)
        temp56 = 4 * x5 * x6 /((1+x5-x6) * (1-x5+x6)) * self.PE_2((1+x5-x6)/2,(1+x6-x5)/2,l0_56, l1_56, l2_56, l3_56)


        PE = temp12 + temp23 + temp13 +temp14 + temp24 + temp34 + temp15 + temp25 + temp35 + temp45+ temp16 + temp26 + temp36 + temp46 + temp56

        return PE

    def Koler(self,x1,x2,x3,l0_12,l1_12,l2_12,l3_12,l0_23,l1_23,l2_23,l3_23,l0_13, l1_13, l2_13, l3_13):

        temp1 = pow(x1+x2,2)* self.PE_2(x1/(x1+x2),x2/(x1+x2),l0_12,l1_12, l2_12, l3_12)
        temp2 = pow(x2+x3,2)* self.PE_2(x2/(x2+x3),x3/(x2+x3),l0_23,l1_23, l2_23, l3_23)
        temp3 = pow(x1 + x3, 2) * self.PE_2(x1 / (x1 + x3), x3 / (x1 + x3), l0_13, l1_13, l2_13, l3_13)
        PE = temp1 + temp2 + temp3
        return PE

    def Koler_4(self, x1, x2, x3, x4, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
                   l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34):

        temp12 = pow(x1+x2, 2) * self.PE_2(x1/(x1+x2),x2/(x1+x2),l0_12,l1_12, l2_12, l3_12)
        temp23 = pow(x2+x3, 2) * self.PE_2(x2/(x2+x3),x3/(x2+x3),l0_23,l1_23, l2_23, l3_23)
        temp13 = pow(x1+x3, 2) * self.PE_2(x1 / (x1 + x3), x3 / (x1 + x3), l0_13, l1_13, l2_13, l3_13)
        temp14 = pow(x1+x4, 2) * self.PE_2(x1/(x1+x4),x4/(x1+x4),l0_14,l1_14, l2_14, l3_14)
        temp24 = pow(x2+x4, 2) * self.PE_2(x2/(x2+x4),x4/(x2+x4),l0_24,l1_24, l2_24, l3_24)
        temp34 = pow(x3+x4, 2) * self.PE_2(x3/(x3+x4),x4/(x3+x4),l0_34,l1_34, l2_34, l3_34)

        PE = temp12 + temp23 + temp13 + temp14 + temp24 + temp34
        return PE

    def Koler_5(self, x1, x2, x3, x4, x5, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
                   l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34,l0_15,l1_15,l2_15,l3_15,
                l0_25,l1_25,l2_25,l3_25,l0_35,l1_35,l2_35,l3_35,l0_45,l1_45,l2_45,l3_45):

        temp12 = pow(x1+x2, 2) * self.PE_2(x1/(x1+x2),x2/(x1+x2),l0_12,l1_12, l2_12, l3_12)
        temp23 = pow(x2+x3, 2) * self.PE_2(x2/(x2+x3),x3/(x2+x3),l0_23,l1_23, l2_23, l3_23)
        temp13 = pow(x1+x3, 2) * self.PE_2(x1 / (x1 + x3), x3 / (x1 + x3), l0_13, l1_13, l2_13, l3_13)
        temp14 = pow(x1+x4, 2) * self.PE_2(x1/(x1+x4),x4/(x1+x4),l0_14,l1_14, l2_14, l3_14)
        temp24 = pow(x2+x4, 2) * self.PE_2(x2/(x2+x4),x4/(x2+x4),l0_24,l1_24, l2_24, l3_24)
        temp34 = pow(x3+x4, 2) * self.PE_2(x3/(x3+x4),x4/(x3+x4),l0_34,l1_34, l2_34, l3_34)
        temp15 = pow(x1+x5, 2) * self.PE_2(x1/(x1+x5),x5/(x1+x5),l0_15,l1_15, l2_15, l3_15)
        temp25 = pow(x2+x5, 2) * self.PE_2(x2/(x2+x5),x5/(x2+x5),l0_25,l1_25, l2_25, l3_25)
        temp35 = pow(x3+x5, 2) * self.PE_2(x3/(x3+x5),x5/(x3+x5),l0_35,l1_35, l2_35, l3_35)
        temp45 = pow(x4+x5, 2) * self.PE_2(x4/(x4+x5),x5/(x4+x5),l0_45,l1_45, l2_45, l3_45)

        PE = temp12 + temp23 + temp13 + temp14 + temp24 + temp34 + temp15 + temp25 + temp35 + temp45
        return PE
    def Koler_6(self, x1, x2, x3, x4, x5, x6, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
        l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34,l0_15,l1_15,l2_15,l3_15,
                l0_25,l1_25,l2_25,l3_25,l0_35,l1_35,l2_35,l3_35,l0_45,l1_45,l2_45,l3_45,
        l0_16,l1_16,l2_16,l3_16,l0_26,l1_26, l2_26, l3_26, l0_36,l1_36,l2_36,l3_36,
        l0_46,l1_46,l2_46,l3_46,l0_56,l1_56,l2_56,l3_56):

        temp12 = pow(x1+x2, 2) * self.PE_2(x1/(x1+x2),x2/(x1+x2),l0_12,l1_12, l2_12, l3_12)
        temp23 = pow(x2+x3, 2) * self.PE_2(x2/(x2+x3),x3/(x2+x3),l0_23,l1_23, l2_23, l3_23)
        temp13 = pow(x1+x3, 2) * self.PE_2(x1 / (x1 + x3), x3 / (x1 + x3), l0_13, l1_13, l2_13, l3_13)
        temp14 = pow(x1+x4, 2) * self.PE_2(x1/(x1+x4),x4/(x1+x4),l0_14,l1_14, l2_14, l3_14)
        temp24 = pow(x2+x4, 2) * self.PE_2(x2/(x2+x4),x4/(x2+x4),l0_24,l1_24, l2_24, l3_24)
        temp34 = pow(x3+x4, 2) * self.PE_2(x3/(x3+x4),x4/(x3+x4),l0_34,l1_34, l2_34, l3_34)
        temp15 = pow(x1+x5, 2) * self.PE_2(x1/(x1+x5),x5/(x1+x5),l0_15,l1_15, l2_15, l3_15)
        temp25 = pow(x2+x5, 2) * self.PE_2(x2/(x2+x5),x5/(x2+x5),l0_25,l1_25, l2_25, l3_25)
        temp35 = pow(x3+x5, 2) * self.PE_2(x3/(x3+x5),x5/(x3+x5),l0_35,l1_35, l2_35, l3_35)
        temp45 = pow(x4+x5, 2) * self.PE_2(x4/(x4+x5),x5/(x4+x5),l0_45,l1_45, l2_45, l3_45)
        temp16 = pow(x1+x6, 2) * self.PE_2(x1/(x1+x6),x6/(x1+x6),l0_16,l1_16, l2_16, l3_16)
        temp26 = pow(x2+x6, 2) * self.PE_2(x2/(x2+x6),x6/(x2+x6),l0_26,l1_26, l2_26, l3_26)
        temp36 = pow(x3+x6, 2) * self.PE_2(x3/(x3+x6),x6/(x3+x6),l0_36,l1_36, l2_36, l3_36)
        temp46 = pow(x4+x6, 2) * self.PE_2(x4/(x4+x6),x6/(x4+x6),l0_46,l1_46, l2_46, l3_46)
        temp56 = pow(x5+x6, 2) * self.PE_2(x5/(x5+x6),x6/(x5+x6),l0_56,l1_56, l2_56, l3_56)

        PE = temp12 + temp23 + temp13 + temp14 + temp24 + temp34 + temp15 + temp25 + temp35 + temp45 + temp16 + temp26 + temp36 + temp46 + temp56
        return PE
    def Chou(self,x1,x2,x3,l0_12,l1_12,l2_12,l3_12,l0_23,l1_23,l2_23,l3_23,l0_13, l1_13, l2_13, l3_13):

        temp1 = x2/(1-x1) * self.PE_2(x1,1-x1,l0_12,l1_12, l2_12, l3_12)
        temp2 = x3/(1-x2) * self.PE_2(x2,1-x2,l0_23,l1_23, l2_23, l3_23)
        temp3 = x1/(1-x3) * self.PE_2(1-x3, x3, l0_13, l1_13, l2_13, l3_13)
        PE = temp1 + temp2 + temp3
        return PE

    def Chou_4(self, x1, x2, x3, x4, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
                   l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34):

        temp12 = x2/(1-x1) * self.PE_2(x1,1-x1,l0_12,l1_12, l2_12, l3_12)
        temp23 = x3/(1-x2) * self.PE_2(x2,1-x2,l0_23,l1_23, l2_23, l3_23)
        temp13 = x1/(1-x3) * self.PE_2(1-x3, x3, l0_13, l1_13, l2_13, l3_13)
        temp14 = x4/(1-x1) * self.PE_2(1-x4, x4, l0_14, l1_14, l2_14, l3_14)
        temp24 = x4/(1-x2) * self.PE_2(x2, 1-x2, l0_24, l1_24, l2_24, l3_24)
        temp34 = x4/(1-x3) * self.PE_2(x3, 1-x3, l0_34, l1_34, l2_34, l3_34)

        PE = temp12 + temp23 + temp13 + temp14 + temp24 + temp34
        return PE

    def Chou_5(self, x1, x2, x3, x4, x5, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
                   l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34,l0_15,l1_15,l2_15,l3_15,
                l0_25,l1_25,l2_25,l3_25,l0_35,l1_35,l2_35,l3_35,l0_45,l1_45,l2_45,l3_45):

        temp12 = x2/(1-x1) * self.PE_2(x1,1-x1,l0_12,l1_12, l2_12, l3_12)
        temp23 = x3/(1-x2) * self.PE_2(x2,1-x2,l0_23,l1_23, l2_23, l3_23)
        temp13 = x1/(1-x3) * self.PE_2(1-x3, x3, l0_13, l1_13, l2_13, l3_13)
        temp14 = x4/(1-x1) * self.PE_2(1-x4, x4, l0_14, l1_14, l2_14, l3_14)
        temp24 = x4/(1-x2) * self.PE_2(x2, 1-x2, l0_24, l1_24, l2_24, l3_24)
        temp34 = x4/(1-x3) * self.PE_2(x3, 1-x3, l0_34, l1_34, l2_34, l3_34)
        temp15 = x5/(1-x1) * self.PE_2(1-x5, x5, l0_15, l1_15, l2_15, l3_15)
        temp25 = x5/(1-x2) * self.PE_2(x2, 1-x2, l0_25, l1_25, l2_25, l3_25)
        temp35 = x5/(1-x3) * self.PE_2(x3, 1-x3, l0_35, l1_35, l2_35, l3_35)
        temp45 = x5/(1-x4) * self.PE_2(x4, 1-x4, l0_45, l1_45, l2_45, l3_45)

        PE = temp12 + temp23 + temp13 + temp14 + temp24 + temp34 + temp15 + temp25 + temp35 + temp45
        return PE
    def Chou_6(self, x1, x2, x3, x4, x5, x6, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
        l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34,l0_15,l1_15,l2_15,l3_15,
        l0_25,l1_25,l2_25,l3_25,l0_35,l1_35,l2_35,l3_35,l0_45,l1_45,l2_45,l3_45,
        l0_16,l1_16,l2_16,l3_16,l0_26,l1_26, l2_26, l3_26, l0_36,l1_36,l2_36,l3_36,
        l0_46,l1_46,l2_46,l3_46,l0_56,l1_56,l2_56,l3_56):

        temp12 = x2/(1-x1) * self.PE_2(x1,1-x1,l0_12,l1_12, l2_12, l3_12)
        temp23 = x3/(1-x2) * self.PE_2(x2,1-x2,l0_23,l1_23, l2_23, l3_23)
        temp13 = x1/(1-x3) * self.PE_2(1-x3, x3, l0_13, l1_13, l2_13, l3_13)
        temp14 = x4/(1-x1) * self.PE_2(1-x4, x4, l0_14, l1_14, l2_14, l3_14)
        temp24 = x4/(1-x2) * self.PE_2(x2, 1-x2, l0_24, l1_24, l2_24, l3_24)
        temp34 = x4/(1-x3) * self.PE_2(x3, 1-x3, l0_34, l1_34, l2_34, l3_34)
        temp15 = x5/(1-x1) * self.PE_2(1-x5, x5, l0_15, l1_15, l2_15, l3_15)
        temp25 = x5/(1-x2) * self.PE_2(x2, 1-x2, l0_25, l1_25, l2_25, l3_25)
        temp35 = x5/(1-x3) * self.PE_2(x3, 1-x3, l0_35, l1_35, l2_35, l3_35)
        temp45 = x5/(1-x4) * self.PE_2(x4, 1-x4, l0_45, l1_45, l2_45, l3_45)
        temp16 = x6/(1-x1) * self.PE_2(1-x6, x6, l0_16, l1_16, l2_16, l3_16)
        temp26 = x6/(1-x2) * self.PE_2(x2, 1-x2, l0_26, l1_26, l2_26, l3_26)
        temp36 = x6/(1-x3) * self.PE_2(x3, 1-x3, l0_36, l1_36, l2_36, l3_36)
        temp46 = x6/(1-x4) * self.PE_2(x4, 1-x4, l0_46, l1_46, l2_46, l3_46)
        temp56 = x6/(1-x4) * self.PE_2(x5, 1-x5, l0_56, l1_56, l2_56, l3_56)

        PE = temp12 + temp23 + temp13 + temp14 + temp24 + temp34 + temp15 + temp25 + temp35 + temp45 + temp16 + temp26 + temp36 + temp46 + temp56
        return PE
    def Toop(self,x1,x2,x3,l0_12,l1_12,l2_12,l3_12,l0_23,l1_23,l2_23,l3_23,l0_13, l1_13, l2_13, l3_13):

        temp12 = x2/(1-x1) * self.PE_2(x1, 1-x1, l0_12, l1_12, l2_12, l3_12)
        temp23 = pow(x2+x3, 2) * self.PE_2(x2/(x2+x3), x3/(x2+x3), l0_23, l1_23, l2_23, l3_23)
        temp13 = x3/(1-x1) * self.PE_2(x1, 1-x1, l0_13, l1_13, l2_13, l3_13)

        PE = temp12 + temp23 + temp13
        return PE

    def Toop_4(self, x1, x2, x3, x4, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
                   l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34):

        temp12 = x2/(1-x1) * self.PE_2(x1, 1-x1, l0_12, l1_12, l2_12, l3_12)
        temp23 = pow(x2+x3, 2) * self.PE_2(x2/(x2+x3), x3/(x2+x3), l0_23, l1_23, l2_23, l3_23)
        temp13 = x3/(1-x1) * self.PE_2(x1, 1-x1, l0_13, l1_13, l2_13, l3_13)
        temp14 = x4/(1-x1) * self.PE_2(x1, 1-x1, l0_14, l1_14, l2_14, l3_14)
        temp24 = pow(x2+x4, 2) * self.PE_2(x2/(x2+x4), x4/(x2+x4), l0_24, l1_24, l2_24, l3_24)
        temp34 = pow(x3+x4, 2) * self.PE_2(x3/(x3+x4), x4/(x3+x4), l0_34, l1_34, l2_34, l3_34)

        PE = temp12 + temp23 + temp13 + temp14 + temp24 + temp34

        return PE
    def Toop_5(self, x1, x2, x3, x4, x5, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
                   l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34,l0_15,l1_15,l2_15,l3_15,
                l0_25,l1_25,l2_25,l3_25,l0_35,l1_35,l2_35,l3_35,l0_45,l1_45,l2_45,l3_45):

        temp12 = x2/(1-x1) * self.PE_2(x1, 1-x1, l0_12, l1_12, l2_12, l3_12)
        temp23 = pow(x2+x3, 2) * self.PE_2(x2/(x2+x3), x3/(x2+x3), l0_23, l1_23, l2_23, l3_23)
        temp13 = x3/(1-x1) * self.PE_2(x1, 1-x1, l0_13, l1_13, l2_13, l3_13)
        temp14 = x4/(1-x1) * self.PE_2(x1, 1-x1, l0_14, l1_14, l2_14, l3_14)
        temp24 = pow(x2+x4, 2) * self.PE_2(x2/(x2+x4), x4/(x2+x4), l0_24, l1_24, l2_24, l3_24)
        temp34 = pow(x3+x4, 2) * self.PE_2(x3/(x3+x4), x4/(x3+x4), l0_34, l1_34, l2_34, l3_34)
        temp15 = x5 / (1 - x1) * self.PE_2(x1, 1 - x1, l0_15, l1_15, l2_15, l3_15)
        temp25 = pow(x2 + x5, 2) * self.PE_2(x2 / (x2 + x5), x5 / (x2 + x5), l0_25, l1_25, l2_25, l3_25)
        temp35 = pow(x3 + x5, 2) * self.PE_2(x3 / (x3 + x5), x5 / (x3 + x5), l0_35, l1_35, l2_35, l3_35)
        temp45 = pow(x4 + x5, 2) * self.PE_2(x4 / (x4 + x5), x5 / (x4 + x5), l0_45, l1_45, l2_45, l3_45)

        PE = temp12 + temp23 + temp13 + temp14 + temp24 + temp34 + temp15 + temp25 + temp35 + temp45

        return PE
    def Toop_6(self, x1, x2, x3, x4, x5, x6, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
        l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34,l0_15,l1_15,l2_15,l3_15,
        l0_25,l1_25,l2_25,l3_25,l0_35,l1_35,l2_35,l3_35,l0_45,l1_45,l2_45,l3_45,
        l0_16,l1_16,l2_16,l3_16,l0_26,l1_26, l2_26, l3_26, l0_36,l1_36,l2_36,l3_36,
        l0_46,l1_46,l2_46,l3_46,l0_56,l1_56,l2_56,l3_56):

        temp12 = x2/(1-x1) * self.PE_2(x1, 1-x1, l0_12, l1_12, l2_12, l3_12)
        temp23 = pow(x2+x3, 2) * self.PE_2(x2/(x2+x3), x3/(x2+x3), l0_23, l1_23, l2_23, l3_23)
        temp13 = x3/(1-x1) * self.PE_2(x1, 1-x1, l0_13, l1_13, l2_13, l3_13)
        temp14 = x4/(1-x1) * self.PE_2(x1, 1-x1, l0_14, l1_14, l2_14, l3_14)
        temp24 = pow(x2+x4, 2) * self.PE_2(x2/(x2+x4), x4/(x2+x4), l0_24, l1_24, l2_24, l3_24)
        temp34 = pow(x3+x4, 2) * self.PE_2(x3/(x3+x4), x4/(x3+x4), l0_34, l1_34, l2_34, l3_34)
        temp15 = x5 / (1 - x1) * self.PE_2(x1, 1 - x1, l0_15, l1_15, l2_15, l3_15)
        temp25 = pow(x2 + x5, 2) * self.PE_2(x2 / (x2 + x5), x5 / (x2 + x5), l0_25, l1_25, l2_25, l3_25)
        temp35 = pow(x3 + x5, 2) * self.PE_2(x3 / (x3 + x5), x5 / (x3 + x5), l0_35, l1_35, l2_35, l3_35)
        temp45 = pow(x4 + x5, 2) * self.PE_2(x4 / (x4 + x5), x5 / (x4 + x5), l0_45, l1_45, l2_45, l3_45)
        temp16 = x6 / (1 - x1) * self.PE_2(x1, 1 - x1, l0_16, l1_16, l2_16, l3_16)
        temp26 = pow(x2 + x6, 2) * self.PE_2(x2 / (x2 + x6), x6 / (x2 + x6), l0_26, l1_26, l2_26, l3_26)
        temp36 = pow(x3 + x6, 2) * self.PE_2(x3 / (x3 + x6), x6 / (x3 + x6), l0_36, l1_36, l2_36, l3_36)
        temp46 = pow(x4 + x6, 2) * self.PE_2(x4 / (x4 + x6), x6 / (x4 + x6), l0_46, l1_46, l2_46, l3_46)
        temp56 = pow(x5 + x6, 2) * self.PE_2(x5 / (x5 + x6), x6 / (x5 + x6), l0_56, l1_56, l2_56, l3_56)

        PE = temp12 + temp23 + temp13 + temp14 + temp24 + temp34 + temp15 + temp25 + temp35 + temp45 + temp16 + temp26 + temp36 + temp46 + temp56

        return PE
    def Hillert(self,x1,x2,x3,l0_12,l1_12,l2_12,l3_12,l0_23,l1_23,l2_23,l3_23,l0_13, l1_13, l2_13, l3_13):

        temp12 = x2/(1-x1) * self.PE_2(x1,1-x1,l0_12,l1_12, l2_12, l3_12)
        temp23 = 4 * x2 * x3 /((1+x2-x3)*(1-x2+x3)) * self.PE_2((1+x2-x3)/2,(1+x3-x2)/2,l0_23,l1_23, l2_23, l3_23)
        temp13 = x3/(1-x1) * self.PE_2(x1, 1-x1, l0_13, l1_13, l2_13, l3_13)

        PE = temp12 + temp23 + temp13

        return PE

    def Hillert_4(self, x1, x2, x3, x4, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
                   l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34):
        temp12 = x2 / (1 - x1) * self.PE_2(x1, 1 - x1, l0_12, l1_12, l2_12, l3_12)
        temp23 = 4 * x2 * x3 / ((1 + x2 - x3) * (1 - x2 + x3)) * self.PE_2((1 + x2 - x3) / 2, (1 + x3 - x2) / 2, l0_23, l1_23, l2_23, l3_23)
        temp13 = x3 / (1 - x1) * self.PE_2(x1, 1 - x1, l0_13, l1_13, l2_13, l3_13)
        temp14 = x4 / (1 - x1) * self.PE_2(x1, 1 - x1, l0_14, l1_14, l2_14, l3_14)
        temp24 = 4 * x2 * x4 /((1+x2-x4) * (1-x2+x4)) * self.PE_2((1+x2-x4)/2,(1+x4-x2)/2,l0_24, l1_24, l2_24, l3_24)
        temp34 = 4 * x3 * x4 /((1+x3-x4) * (1-x3+x4)) * self.PE_2((1+x3-x4)/2,(1+x4-x3)/2,l0_34, l1_34, l2_34, l3_34)

        PE = temp12 + temp23 + temp13 + temp14 + temp24 + temp34

        return PE
    def Hillert_5(self, x1, x2, x3, x4, x5, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
                   l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34,l0_15,l1_15,l2_15,l3_15,
                l0_25,l1_25,l2_25,l3_25,l0_35,l1_35,l2_35,l3_35,l0_45,l1_45,l2_45,l3_45):
        temp12 = x2 / (1 - x1) * self.PE_2(x1, 1 - x1, l0_12, l1_12, l2_12, l3_12)
        temp23 = 4 * x2 * x3 / ((1 + x2 - x3) * (1 - x2 + x3)) * self.PE_2((1 + x2 - x3) / 2, (1 + x3 - x2) / 2, l0_23, l1_23, l2_23, l3_23)
        temp13 = x3 / (1 - x1) * self.PE_2(x1, 1 - x1, l0_13, l1_13, l2_13, l3_13)
        temp14 = x4 / (1 - x1) * self.PE_2(x1, 1 - x1, l0_14, l1_14, l2_14, l3_14)
        temp24 = 4 * x2 * x4 /((1+x2-x4) * (1-x2+x4)) * self.PE_2((1+x2-x4)/2,(1+x4-x2)/2,l0_24, l1_24, l2_24, l3_24)
        temp34 = 4 * x3 * x4 /((1+x3-x4) * (1-x3+x4)) * self.PE_2((1+x3-x4)/2,(1+x4-x3)/2,l0_34, l1_34, l2_34, l3_34)
        temp15 = x5 / (1 - x1) * self.PE_2(x1, 1 - x1, l0_15, l1_15, l2_15, l3_15)
        temp25 = 4 * x2 * x5 /((1+x2-x5) * (1-x2+x5)) * self.PE_2((1+x2-x5)/2,(1+x5-x2)/2,l0_25, l1_25, l2_25, l3_25)
        temp35 = 4 * x3 * x5 /((1+x3-x5) * (1-x3+x5)) * self.PE_2((1+x3-x5)/2,(1+x5-x3)/2,l0_35, l1_35, l2_35, l3_35)
        temp45 = 4 * x4 * x5 /((1+x4-x5) * (1-x4+x5)) * self.PE_2((1+x4-x5)/2,(1+x5-x4)/2,l0_45, l1_45, l2_45, l3_45)

        PE = temp12 + temp23 + temp13 + temp14 + temp24 + temp34 + temp15 + temp25 + temp35 + temp45

        return PE
    def Hillert_6(self, x1, x2, x3, x4, x5, x6, l0_12, l1_12, l2_12, l3_12, l0_23, l1_23, l2_23, l3_23, l0_13, l1_13, l2_13, l3_13,
        l0_14,l1_14,l2_14,l3_14,l0_24,l1_24,l2_24,l3_24,l0_34,l1_34,l2_34,l3_34,l0_15,l1_15,l2_15,l3_15,
        l0_25,l1_25,l2_25,l3_25,l0_35,l1_35,l2_35,l3_35,l0_45,l1_45,l2_45,l3_45,
        l0_16,l1_16,l2_16,l3_16,l0_26,l1_26, l2_26, l3_26, l0_36,l1_36,l2_36,l3_36,
        l0_46,l1_46,l2_46,l3_46,l0_56,l1_56,l2_56,l3_56):

        temp12 = x2 / (1 - x1) * self.PE_2(x1, 1 - x1, l0_12, l1_12, l2_12, l3_12)
        temp23 = 4 * x2 * x3 / ((1 + x2 - x3) * (1 - x2 + x3)) * self.PE_2((1 + x2 - x3) / 2, (1 + x3 - x2) / 2, l0_23, l1_23, l2_23, l3_23)
        temp13 = x3 / (1 - x1) * self.PE_2(x1, 1 - x1, l0_13, l1_13, l2_13, l3_13)
        temp14 = x4 / (1 - x1) * self.PE_2(x1, 1 - x1, l0_14, l1_14, l2_14, l3_14)
        temp24 = 4 * x2 * x4 /((1+x2-x4) * (1-x2+x4)) * self.PE_2((1+x2-x4)/2,(1+x4-x2)/2,l0_24, l1_24, l2_24, l3_24)
        temp34 = 4 * x3 * x4 /((1+x3-x4) * (1-x3+x4)) * self.PE_2((1+x3-x4)/2,(1+x4-x3)/2,l0_34, l1_34, l2_34, l3_34)
        temp15 = x5 / (1 - x1) * self.PE_2(x1, 1 - x1, l0_15, l1_15, l2_15, l3_15)
        temp25 = 4 * x2 * x5 /((1+x2-x5) * (1-x2+x5)) * self.PE_2((1+x2-x5)/2,(1+x5-x2)/2,l0_25, l1_25, l2_25, l3_25)
        temp35 = 4 * x3 * x5 /((1+x3-x5) * (1-x3+x5)) * self.PE_2((1+x3-x5)/2,(1+x5-x3)/2,l0_35, l1_35, l2_35, l3_35)
        temp45 = 4 * x4 * x5 /((1+x4-x5) * (1-x4+x5)) * self.PE_2((1+x4-x5)/2,(1+x5-x4)/2,l0_45, l1_45, l2_45, l3_45)
        temp16 = x6 / (1 - x1) * self.PE_2(x1, 1 - x1, l0_16, l1_16, l2_16, l3_16)
        temp26 = 4 * x2 * x6 /((1+x2-x6) * (1-x2+x6)) * self.PE_2((1+x2-x6)/2,(1+x6-x2)/2,l0_26, l1_26, l2_26, l3_26)
        temp36 = 4 * x3 * x6 /((1+x3-x6) * (1-x3+x6)) * self.PE_2((1+x3-x6)/2,(1+x6-x3)/2,l0_36, l1_36, l2_36, l3_36)
        temp46 = 4 * x4 * x6 /((1+x4-x6) * (1-x4+x6)) * self.PE_2((1+x4-x6)/2,(1+x6-x4)/2,l0_46, l1_46, l2_46, l3_46)
        temp56 = 4 * x5 * x6 /((1+x5-x6) * (1-x5+x6)) * self.PE_2((1+x5-x6)/2,(1+x6-x5)/2,l0_56, l1_56, l2_56, l3_56)

        PE = temp12 + temp23 + temp13 + temp14 + temp24 + temp34 + temp15 + temp25 + temp35 + temp45 + temp16 + temp26 + temp36 + temp46 + temp56

        return PE